home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
visds
/
multidlg.dsc
< prev
next >
Wrap
Text File
|
1999-05-02
|
3KB
|
88 lines
title Child Dialog Test
REM Demonstrate creating and using a child dialog
DIALOG CREATE,Main Dialog,20,20,220,166,SAVEPOS Main
DIALOG ADD,LIST,LIST1,10,10,198,96
DIALOG ADD,BUTTON,Add,116,10,,,,default
DIALOG ADD,BUTTON,Close,116,144,64,24
DIALOG ADD,STATUS,SB,Click Add to add an item of text to the list
DIALOG SHOW
:Main_evloop
wait event
%E = @event()
goto %E
:AddBUTTON
goto Child_Dialog
:CloseBUTTON
:CLOSE
exit
:Child_Dialog
DIALOG CREATE,Child Dialog,20,0,284,72,SAVEPOS Child,NOMIN
DIALOG ADD,EDIT,CEDIT1,10,10
DIALOG ADD,BUTTON,OK,8,206,,,,default
DIALOG ADD,BUTTON,Cancel,36,206,64,24
DIALOG ADD,BUTTON,Help,36,10,64,24,Help
DIALOG SHOW
REM With a non-modal child dialog any of the buttons and dialog
REM elements can generate events, including those on other dialogs,
REM and so you have to find out which dialog they came from by
REM using @event(D). For most applications, as here, while the
REM child dialog is showing you don't want to respond to events
REM from the main window so the usual response is to sound a warning
REM beep and activate the dialog the user is supposed to be using.
REM It is possible to write scripts in which events can legitimately
REM be received from any dialog that is showing (such as the VDS
REM Dialog Designer) but this is complicated stuff for advanced
REM programmers only.
REM The main advantage of using a non-modal DIALOG SHOW is that
REM it allows you to do other things while the child dialog is
REM active. Here, we validate that some data has been entered in
REM the edit box, and display a warning if there isn't any. We have
REM also added a Help button which could be used to call up online
REM help.
:Child_evloop
wait event
parse "%E;%D",@event(D)
if @zero(%D)
beep
dialog select,1
dialog focus,CEDIT1
goto Child_evloop
else
goto Child_%E
end
:Child_HelpBUTTON
info You clicked the Help button!
goto Child_evloop
:Child_OKBUTTON
dialog select,1
%A = @dlgtext(cedit1)
if @null(%A)
warn No data entered!
goto Child_evloop
end
dialog select,0
list add,list1,%A
dialog select,1
:Child_CancelBUTTON
:Child_CLOSE
REM Even in the event of clicking the close button, you must still
REM explicitly close the child dialog. This is to give you a chance
REM to recover any data from it.
DIALOG CLOSE
REM Wait for the CLOSE event that this generates...
wait event
REM ...and throw it away (otherwise it will be executed by the main
REM event loop!)
%E = @event()
goto Main_evloop